var dbUtil = require("db-util")
const db = uniCloud.database()
const dbCmd = db.command
module.exports = {   
    trigger: {
        beforeDelete: async ({docId} = {}) => {
			let e = await dbUtil.getById({
				collection: 't3ds-store-industry',
				id: docId
			})
			if (!e) {
				throw new Error('记录不存在！')
			}
			let count = await dbUtil.getCount({
				collection: 't3ds-store-industry-item',
				where: {
					storeId: e.storeId,
					industryId: e.industryId
				}
			})
			if (count) {
				throw new Error('请先清空该行业下的游戏！')
			}
		}
    }
}
